package com.beyond.trace.service.impl.agricultural;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.beyond.trace.domain.agricultural.AgriculturalIdentify;
import com.beyond.trace.domain.agricultural.AgriculturalSuggest;
import com.beyond.trace.mapper.agricultural.AgriculturalIdentifyMapper;
import com.beyond.trace.mapper.agricultural.AgriculturalSuggestMapper;
import com.beyond.trace.service.agricultural.IAgriculturalIdentifyService;
import com.beyond.trace.service.agricultural.IAgriculturalSuggestService;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description 农技防控建议
 * @Author: yaojianbo
 * @Date: 2023-05-22 11:35
 * @Version: 1.0.0
 */
@Service
public class AgriculturalSuggestServiceImpl extends ServiceImpl<AgriculturalSuggestMapper, AgriculturalSuggest> implements IAgriculturalSuggestService {

    public List<AgriculturalSuggest> getSuggestList(AgriculturalSuggest agriculturalSuggest){

        LambdaQueryWrapper<AgriculturalSuggest> queryWrapper = new LambdaQueryWrapper<>();

        if(!SecurityUtils.isAdmin(SecurityUtils.getUserId())){
            queryWrapper.eq(AgriculturalSuggest::getDepartId,SecurityUtils.getUserDepartId());
        }

        if(StringUtils.isNotEmpty(agriculturalSuggest.getCycle())) {
            queryWrapper.eq(AgriculturalSuggest::getCycle,agriculturalSuggest.getCycle());
        }
        if(agriculturalSuggest.getStatus() != null) {
            queryWrapper.eq(AgriculturalSuggest::getStatus,agriculturalSuggest.getStatus());
        }
        return this.list(queryWrapper);
    }

}
